package com.caoaman.sharding.controller;

import com.caoaman.sharding.model.User;
import com.caoaman.sharding.service.UserService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ClassName: UserController
 * @Description: 用户控制器
 * @Author: CaoAMan
 * @Create: 2021-12-08 17:26
 */
@RestController
@RequestMapping("user")
public class UserController {

    @Resource
    private UserService userService;

    @GetMapping("/select")
    public List<User> select() {
        return userService.lambdaQuery().orderByDesc(User::getId).list();
    }

    @PostMapping("/insert")
    public Boolean insert(@RequestBody User user) {
        return userService.save(user);
    }
}
